﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：AccessPermissionsDistributionInfo
// 文件功能描述：门禁权限分配业务逻辑层
//
// 
// 创建标识：2012-07-06 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class AccessPermissionsDistributionInfo
    {
        public int PID
        {
            get;
            set;
        }
        /// <summary>
        /// 部门名称
        /// </summary>
        public string deptName
        {
            get;
            set;
        }
        /// <summary>
        /// 人员编号
        /// </summary>
        public string EmpNo
        {
            get;
            set;
        }
        /// <summary>
        /// 人员姓名
        /// </summary>
        public string PName
        {
            get;
            set;
        }
        /// <summary>
        /// 设备组名称
        /// </summary>
        public string NodeName
        {
            get;
            set;
        }
        /// <summary>
        /// 采集时间
        /// </summary>
        public DateTime RECORDDATETIME
        {
            get;
            set;
        }
        /// <summary>
        /// 卡序列号
        /// </summary>
        public string CardSerial
        {
            get;
            set;
        }
        public string rownumber
        {
            get;
            set;
        }
        /// <summary>
        /// 门禁ID
        /// </summary>
        public string MJId
        {
            get;
            set;
        }
        /// <summary>
        /// 门禁名称
        /// </summary>
        public string MJName
        {
            get;
            set;
        }

        public DateTime DateTime
        {
            get;
            set;
        }
        private DataAccessAccessPermissionsDistribution dar;

        public AccessPermissionsDistributionInfo()
        {
            dar = new DataAccessAccessPermissionsDistribution();
        }
        /// <summary>
        /// 获取部门列表（用于绑定下拉框）
        /// </summary>
        /// <returns></returns>
        public DataSet GetdeptName()
        {
            return dar.GetdeptName();
        }
        /// <summary>
        /// 获取门名称列表（用于绑定下拉框）
        /// </summary>
        /// <returns></returns>
        public DataSet GetMachine()
        {
            return dar.GetMachine();
        }

        /// <summary>
        /// 获取已发卡且状态为正常的卡的列表（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<AccessPermissionsDistributionInfo> GetList(int pagesize, int startindex, string strquery)
        {
            IList<AccessPermissionsDistributionInfo> funlist = new List<AccessPermissionsDistributionInfo>();
            AccessPermissionsDistributionInfo funinfo;
            DataSet ds = dar.GetList(pagesize, startindex, strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                funinfo = new AccessPermissionsDistributionInfo()
                {
                    PID = Convert.ToInt32(item["PID"]),
                    EmpNo = item["EmpNo"].ToString(),
                    PName = item["姓名"].ToString(),
                    NodeName = item["设备名称"].ToString(),
                    deptName = item["部门名称"].ToString(),
                    CardSerial = item["卡序列号"].ToString(),
                    rownumber = item["rownumber"].ToString(),
                    RECORDDATETIME = Convert.ToDateTime(item["RECORDDATETIME"])
                };
                funlist.Add(funinfo);
            }
            return funlist;
        }

        public int GetCount(string strquery)
        {
            return dar.GetCount(strquery);
        }

        public IList<AccessPermissionsDistributionInfo> SelLeftBox(string strquery)
        {
            IList<AccessPermissionsDistributionInfo> funlist = new List<AccessPermissionsDistributionInfo>();
            AccessPermissionsDistributionInfo funinfo;
            DataSet ds = dar.SelLeftBox(strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                funinfo = new AccessPermissionsDistributionInfo()
                {
                    EmpNo = item["EmpNo"].ToString(),
                    PName = item["PName"].ToString()
                };
                funlist.Add(funinfo);
            }
            return funlist;
        }

        public List<AccessPermissionsDistributionInfo> GetModularAll()
        {
            DataSet ds = dar.GetModular();
            List<AccessPermissionsDistributionInfo> mulist = new List<AccessPermissionsDistributionInfo>();
            AccessPermissionsDistributionInfo muinfo;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                muinfo = new AccessPermissionsDistributionInfo()
                {
                    MJId = dr[0].ToString(),
                    MJName = dr[1].ToString()
                };
                mulist.Add(muinfo);
            }
            return mulist;
        }

        public string BindMenuToRole(string meid, string EMPNO, string Name)
        {
            return dar.BindMenuToRole(meid, EMPNO, Name);
        }

        public string BindMenuToRoleEdit(string meid, string EMPNO, string Name)
        {
            return dar.BindMenuToRoleEdit(meid, EMPNO, Name);
        }

        /// <summary>
        /// 获取岗位列表（用于绑定下拉框）
        /// </summary>
        /// <returns></returns>
        public DataSet GetStructrueName()
        {
            return dar.GetStructrueName();
        }
    }
}
